//
//  Define.h
//  DailyPoem
//
//  Created by liunian on 12-11-16.
//  Copyright (c) 2012年 liunian. All rights reserved.
//

#ifndef DailyPoem_Define_h
#define DailyPoem_Define_h

#import "Util.h"
#import "Debug.h"
#import "UIColor+extend.h"
#import "NSDate+Helper.h"
#import "UIColor+MLPFlatColors.h"
/*
 *  APP信息
 */
#define APP_NAME    [[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"] stringValue]
#define APP_VERSION [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]
#define APP_DEV     @"iphone"
#define DEV_UUID    @""



#define IOS7_OR_LATER   ( [[[UIDevice currentDevice] systemVersion] compare:@"7.0"] != NSOrderedAscending )

#define BUGetElemForKeyFromDict(__key, __dict) [Util getElementForKey:__key fromDict:__dict]
#define BUGetObjFromDict(__key, __dict, __class) [Util getElementForKey:__key fromDict:__dict forClass:__class]

#define BUGetWBEngineForSina  [WBEngineManager getWBEngineSinaWithAppKey:SINAAPPKEY appSecret:SINAAPPSECRET]
#define BUGetWBEngineForTx    [WBEngineManager getWBEngineTXWithAppKey:TXAPPKEY appSecret:TXAPPSECRET]

#define DICT_KEY_SINA_WEIBO_USERINFO    @"DICT_KEY_SINA_WEIBO_USERINFO"
#define DICT_KEY_TENCENT_WEIBO_USERINFO @"DICT_KEY_TENCENT_WEIBO_USERINFO"
#define DICT_KEY_PUSH_DEVICE_TOKEN      @"DICT_KEY_PUSH_DEVICE_TOKEN"

#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)

#define RELEASE_SAFELY(__POINTER) { __POINTER = nil; }
#define REMOVE_SAFELY(__POINTER) { [__POINTER removeFromSuperview]; __POINTER = nil; }
#define INVALIDATE_TIMER(__TIMER) { [__TIMER invalidate]; __TIMER = nil; }

#define IMGFROMBUNDLE( X )	 [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:X ofType:@"" ]]
#define IMGNAMED( X )	     [UIImage imageNamed:X]


#ifndef SET_PARAM
#define SET_PARAM(__value__, __key__, __parms__) \
if (nil!=__value__) {\
[__parms__ setObject:__value__ forKey:__key__];\
}
#endif

#define kDefaultMenuViewHeight            44
#define kDefaultBottomBarHeight           38
#define kDefaultTopBarHeight              39
#define kDefaultColorHeadHeight           3

#define COLOR_RGB(r,g,b)     [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1.0]
#define COLOR_RGBA(r,g,b,a)  [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]

//标题字体定义
#define FONT_TITLE(x)      [UIFont boldSystemFontOfSize:(x)]
//内容字体定义
#define FONT_CONTENT(x)    [UIFont systemFontOfSize:(x)]
//数字字体定义
#define FONT_NUMBER(x)    [UIFont fontWithName:@"DINCond-Light" size:(x)]
//对齐方式
#define ALIGN_LEFT      [Util getAlign:ALIGNTYPE_LEFT]
#define ALIGN_CENTER    [Util getAlign:ALIGNTYPE_CENTER]
#define ALIGN_RIGHT     [Util getAlign:ALIGNTYPE_RIGHT]

//UI 动态布局
#define GetOriginX(UI)              CGRectGetMinX(UI.frame)
#define GetOriginY(UI)              CGRectGetMinY(UI.frame)
#define GetWidth(UI)                CGRectGetWidth(UI.frame)
#define GetHeight(UI)               CGRectGetHeight(UI.frame)
#define OffSetX(UI)                 CGRectGetMaxX(UI.frame)
#define OffSetY(UI)                 CGRectGetMaxY(UI.frame)

/************************************************************************
 *  开发平台引擎 相关
 ************************************************************************/
#define PUGetOFEngineForSina  [OFEngineManager getWBEngineSinaWithAppKey:SINAAPPKEY appSecret:SINAAPPSECRET]
#define PUGetOFEngineForTx    [OFEngineManager getWBEngineTXWithAppKey:TXAPPKEY appSecret:TXAPPSECRET]
#define PUGetOFEngineForQZone [OFEngineManager getQZoneEngineWithAppId:QZONEAPPID appKey:QZONEAPPKEY]

#define SINAAPPKEY           @"148070055"  //sina APPKEY
#define SINAAPPSECRET        @"edd4a338822836551e7981b80785585e"  //sina APPSECRET

#define TXAPPKEY             @""  //tx appkey
#define TXAPPSECRET          @""  //tx APPSECRET

#define QZONEAPPID           @""    //QZONE appId
#define QZONEAPPKEY          @""   //qzone appKey

#define SINA_REDIRECT_URI         @"http://xjan.net"
#define TX_REDIRECT_URI           @"http://"
#define QZONE_REDIRECT_URI        @"http://"
/************************************************************************
 *  开发平台引擎 相关
 ************************************************************************/
//
#define kPushRefreshBodyColor                   [UIColor colorWithRed:212.0/255.0 green:177.0/255.0 blue:138.0/255.0 alpha:1.0f]
#define kPushRefreshSkinColor                   [UIColor clearColor]
#define kSwitchOnTintColor                      [UIColor colorWithRed:84/255.0 green:155/255.0 blue:216/255.0 alpha: 1.0]
#define ATTRIBUTE_INFO(__key__, __className__, __keyClassName__) [NSDictionary dictionaryWithObjectsAndKeys:__key__, @"key",\
__className__, @"className",\
__keyClassName__, @"keyClassName",\
nil]

#define ATTRIBUTE_INFO_NUMBER(__key__) ATTRIBUTE_INFO(__key__, @"NSNull", @"NSNumber")


#define KEY_FROM_ATTRIBUTE_INFO(__info__) [__info__ objectForKey:@"key"]
#define CLASSNAME_FROM_ATTRIBUTE_INFO(__info__) [__info__ objectForKey:@"className"]
#define KEYCLASSNAME_FROM_ATTRIBUTE_INFO(__info__) [__info__ objectForKey:@"keyClassName"]
//

#define KEY_FROM_ATTRIBUTE_INFO(__info__) [__info__ objectForKey:@"key"]
#define CLASSNAME_FROM_ATTRIBUTE_INFO(__info__) [__info__ objectForKey:@"className"]
#define KEYCLASSNAME_FROM_ATTRIBUTE_INFO(__info__) [__info__ objectForKey:@"keyClassName"]

#ifndef isDictWithCountMoreThan0

#define isDictWithCountMoreThan0(__dict__) \
(__dict__!=nil && \
[__dict__ isKindOfClass:[NSDictionary class] ] && \
__dict__.count>0)

#endif

#ifndef isArrayWithCountMoreThan0

#define isArrayWithCountMoreThan0(__array__) \
(__array__!=nil && \
[__array__ isKindOfClass:[NSArray class] ] && \
__array__.count>0)

#endif


#define kBgQueue dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)  




#define UIApplicationhandleAppWillBeginCache  @"UIApplicationhandleAppWillBeginCache"
#define UIApplicationhandleAppDidEndCache  @"UIApplicationhandleAppDidEndCache"

#endif
